<%@ page import =  "com.broadvision.web.util.ViewDynaBean,
		    org.apache.struts.validator.DynaValidatorForm,
                    org.apache.commons.beanutils.PropertyUtils,
                    java.util.List"
%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<% String ctxPath = request.getContextPath(); %>

<jsp:useBean id="cmDocTypeListView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/> 
<bean:size id="resultSize" name="cmDocTypeListView" property="docTypeList"/>

<script language="JavaScript">

function closeWindow() {
  self.close();
}

function setDocType(theForm, index) {
  var parentFormName = theForm.parentFormName.value;
  var parentFieldName = theForm.parentFieldName.value;
  
  var dtype = "theForm.elements['docType[" + index + "].name'].value";
  var name = eval(dtype);
  
  window.opener.setDocType(parentFormName, parentFieldName, name);
  
  var dtypeFName = "theForm.elements['docType[" + index + "].friendlyName'].value";
  var fname = eval(dtypeFName);
  
  window.opener.setDocTypeFName(parentFormName, parentFieldName, fname);
  
  window.close();
}

</script>

<html:form action="/cm/contentTypeSearchPopup.do">
<html:hidden property="parentFormName"/>
<html:hidden property="parentFieldName"/>
<html:hidden property="action" value="search" />
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.docTypeSearch.criteria'/>">
  <tr>
  <td valign="top" width="100%">
  <div class="generalWrapRight">
  <html:button property="closeWinBtn" styleClass="inputButton" onclick="javascript:closeWindow()">
    <bean:message bundle='cm.messages' key='button.close' />
  </html:button>
  </div> 

  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="2" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.docTypeSearch.criteria'/>">
  <tr> 
  <td width="10%" nowrap><b><bean:message bundle='cm.messages' key='cm.content.contentType.label'/>:</b></td>
  <td width="30%" nowrap>
    <html:text property="sName" size="31" maxlength="80" />
  </td>
  
  <td width="60%" nowrap>
    <input hspace="40" type="submit" name="btn_action" class="inputButton" value="<bean:message bundle='cm.messages' key='button.goto'/>">
  </td>
  </tr>
  </table>
  
  <logic:match name="cmDocTypeListView" property="searchResultMsg" value="ShowResults">
    <div class="pageSubtitle">
      <span class="left"><bean:message bundle='cm.messages' key='cm.content.contentType.list'/></span>
      <span class="right">&nbsp;</span>
    </div> 
    
    <table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="<bean:message bundle='cm.messages' key='cm.content.docType.list'/>">
    <tr class="listHeader"> 
      <th id="Name" align="left"><bean:message bundle='cm.messages' key='cm.content.contentType.name'/></th>
      <th id="Friendly Name" align="left"><bean:message bundle='cm.messages' key='cm.content.contentType.fname'/></th>
      <th id="Actions" align="left" nowrap><bean:message bundle='cm.messages' key='cm.content.docType.actions'/></th>
    </tr>     
    
    <logic:equal name="resultSize" value="0">
    <tr class="listEven"> 
      <td colspan="3" valign="top" align="center"><bean:message bundle='cm.messages' key='cm.content.docType.noDocTypeFound'/></td>
    </tr>
    </logic:equal>
  
    <logic:iterate id="docType" name="cmDocTypeListView" property="docTypeList" indexId="index">  
      <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
        <td headers="Name">
          <bean:write name="docType" property="name"/>
          <html:hidden name="docType" property="name" indexed="true"/>
        </td>
        <td headers="Friendly Name">
          <bean:write name="docType" property="friendlyName"/>
          <html:hidden name="docType" property="friendlyName" indexed="true"/>
        </td>
        <td headers="Actions">
          <a href="#" onclick="return setDocType(document.forms[0], '<bean:write name="index"/>')">
            <img src="<%=request.getContextPath()%>/mc/images/action/icon_add.gif" width="15" height="15" border="0" alt='<bean:message bundle='cm.messages' key='image.alt.selectitem'/>' title='<bean:message bundle='cm.messages' key='image.alt.selectitem'/>' >
          </a>
        </td>
      </tr>
    </logic:iterate>
    
    </table>
  </logic:match>
  
  </td>
  </tr>
</table>
</html:form>
